//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_createtyrusermenu.sqf"
#include "x_setup.sqf"

if (!(isNil "TYR_MENU_IsActive") && {TYR_MENU_IsActive > 0}) then {
	if (!isnil "tyr_fnc_addHandler") then {
		["TYRMENU",[
			// Show Status
			[
				localize "STR_DOM_MISSIONSTRING_304"
				,{true}
				,FUNC(showstatus)
				,"pics\settings.paa"
				,100
			],
			// Squad Management
			[
				localize "STR_DOM_MISSIONSTRING_1301"
				,{true}
				,{createDialog "XD_SquadManagementDialog";}
				,"pics\groupmgmt.paa"
				,30
			],
			// Call artillery
			[
				localize "STR_DOM_MISSIONSTRING_153"
				,{([] call FUNC(isAdmin)) || {((!visibleMap && {GVAR(areArtyVecsAvailable)} && {!([] call FUNC(isPara))}) && (GVAR(player_can_call_arti) > 0 || {(if (!isnil "mp_rights_fnc_hasRoles") then {([] call mp_rights_fnc_isMember)} else {false})}))} }
				,{
					_artar = switch (GVAR(player_can_call_arti)) do {
						case 2: {[2, GVAR(AriTarget2)]};
						default {[1, GVAR(AriTarget)]};
					};
					_artar spawn FUNC(artillery);
				}
				,"pics\artillery.paa"
			],
			// Call drop
			[
				localize "STR_DOM_MISSIONSTRING_230"
				,{([] call FUNC(isAdmin)) || {(!visibleMap && {(GVAR(player_can_call_drop) > 0  || {(if (!isnil "mp_rights_fnc_hasRoles") then {([] call mp_rights_fnc_isRecruit)} else {false})})} && {!([] call FUNC(isPara))})}}
				,{0 spawn FUNC(calldrop)}
				,"pics\parachute.paa"
			],
			// Build trench
			[
				localize "STR_DOM_MISSIONSTRING_303"
				,{GVAR(player_can_build_trench) && {!visibleMap} && {vehicle player == player} && {isNull __pGetVar(GVAR(trench))}}
				,{0 spawn FUNC(spawn_trench)}
				,"pics\trench.paa"
			],
			// Build mgnest
			// [
				// localize "STR_DOM_MISSIONSTRING_306"
				// ,{GVAR(player_can_build_mgnest) && {!visibleMap} && {vehicle player == player} && {count __pGetVar(GVAR(mgnest_pos)) == 0}}
				// ,{0 spawn FUNC(spawn_mgnests)}
				// ,"pics\mgnest.paa"
			// ],
			// Build mash
			// [
				// localize "STR_DOM_MISSIONSTRING_305"
				// ,{GVAR(player_is_medic) && {vehicle player == player} && {count __pGetVar(GVAR(medtent)) == 0}}
				// ,{0 spawn FUNC(spawn_mash)}
				// ,"pics\mash.paa"
			// ],
			// Build farp
			// [
				// localize "STR_DOM_MISSIONSTRING_307"
				// ,{GVAR(eng_can_repfuel) && {vehicle player == player} && {count __pGetVar(GVAR(farp_pos)) == 0}}
				// ,{0 spawn FUNC(spawn_farp)}
				// ,"pics\tools.paa"
			// ],
			// Chem light attach
			[
				localize "STR_DOM_MISSIONSTRING_2043"
				,{((player getVariable [QGVAR(p_clattached), ""] == "") && {count (call FUNC(haschemlight)) > 0})}
				,{
					private ["_chemar"];
					_chemar = call FUNC(haschemlight);
					if (count _chemar > 0) then {
						(_chemar select 0) call FUNC(attachchemlight);
					};
				}
				,"pics\chemlight.paa"
			],
			// Chem light detach
			[
				localize "STR_DOM_MISSIONSTRING_1505"
				,{((player getVariable [QGVAR(p_clattached), ""] != ""))}
				,FUNC(detachchemlight)
				,"pics\chemlight.paa"
			],
			// Call Air Taxi
			[
				localize "STR_DOM_MISSIONSTRING_535"
				,{(GVAR(with_ai) || {GVAR(with_ai_features) == 0}) && (([] call FUNC(isAdmin)) || {(!visibleMap && {(GVAR(player_can_call_taxi) > 0 || {(if (!isnil "mp_rights_fnc_hasRoles") then {([] call mp_rights_fnc_isMember)} else {false})})} && {!([] call FUNC(isPara))})})}
				,{ 0 spawn FUNC(airtaxi) }
				,"pics\casevac.paa"
			],
			
			// Admin Spectate
			[
				localize "STR_DOM_MISSIONSTRING_1420"
				,{(([] call FUNC(isAdmin)) || {(if (!isnil "mp_rights_fnc_hasRoles") then {([] call mp_rights_fnc_isAdmin)} else {false})}) && {!visibleMap}}
				,FUNC(adminspectateActionM)
				,"pics\eye.paa"
			]
		]] call tyr_fnc_addHandler;
	};
};